<!DOCTYPE html>
<html>
<!-- Created by GNU Texinfo 7.1, https://www.gnu.org/software/texinfo/ -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<!-- This file documents the use of the GNU compilers.

Copyright © 1988-2023 Free Software Foundation, Inc.

Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
any later version published by the Free Software Foundation; with the
Invariant Sections being "Funding Free Software", the Front-Cover
Texts being (a) (see below), and with the Back-Cover Texts being (b)
(see below).  A copy of the license is included in the section entitled
"GNU Free Documentation License".

(a) The FSF's Front-Cover Text is:

A GNU Manual

(b) The FSF's Back-Cover Text is:

You have freedom to copy and modify this GNU Manual, like GNU
     software.  Copies published by the Free Software Foundation raise
     funds for GNU development. -->
<title>Overall Options (Using the GNU Compiler Collection (GCC))</title>

<meta name="description" content="Overall Options (Using the GNU Compiler Collection (GCC))">
<meta name="keywords" content="Overall Options (Using the GNU Compiler Collection (GCC))">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<meta name="viewport" content="width=device-width,initial-scale=1">

<link href="index.html" rel="start" title="Top">
<link href="Indices.html" rel="index" title="Indices">
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
<link href="Invoking-GCC.html" rel="up" title="Invoking GCC">
<link href="Invoking-G_002b_002b.html" rel="next" title="Invoking G++">
<link href="Option-Summary.html" rel="prev" title="Option Summary">
<style type="text/css">
<!--
a.copiable-link {visibility: hidden; text-decoration: none; line-height: 0em}
div.example {margin-left: 3.2em}
kbd.key {font-style: normal}
span.r {font-family: initial; font-weight: normal; font-style: normal}
span:hover a.copiable-link {visibility: visible}
-->
</style>


</head>

<body lang="en_US">
<div class="section-level-extent" id="Overall-Options">
<div class="nav-panel">
<p>
Next: <a href="Invoking-G_002b_002b.html" accesskey="n" rel="next">Compiling C++ Programs</a>, Previous: <a href="Option-Summary.html" accesskey="p" rel="prev">Option Summary</a>, Up: <a href="Invoking-GCC.html" accesskey="u" rel="up">GCC Command Options</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Indices.html" title="Index" rel="index">Index</a>]</p>
</div>
<hr>
<h3 class="section" id="Options-Controlling-the-Kind-of-Output"><span>3.2 Options Controlling the Kind of Output<a class="copiable-link" href="#Options-Controlling-the-Kind-of-Output"> &para;</a></span></h3>

<p>Compilation can involve up to four stages: preprocessing, compilation
proper, assembly and linking, always in that order.  GCC is capable of
preprocessing and compiling several files either into several
assembler input files, or into one assembler input file; then each
assembler input file produces an object file, and linking combines all
the object files (those newly compiled, and those specified as input)
into an executable file.
</p>
<a class="index-entry-id" id="index-file-name-suffix"></a>
<p>For any given input file, the file name suffix determines what kind of
compilation is done:
</p>
<dl class="table">
<dt><code class="code"><var class="var">file</var>.c</code></dt>
<dd><p>C source code that must be preprocessed.
</p>
</dd>
<dt><code class="code"><var class="var">file</var>.i</code></dt>
<dd><p>C source code that should not be preprocessed.
</p>
</dd>
<dt><code class="code"><var class="var">file</var>.ii</code></dt>
<dd><p>C++ source code that should not be preprocessed.
</p>
</dd>
<dt><code class="code"><var class="var">file</var>.m</code></dt>
<dd><p>Objective-C source code.  Note that you must link with the <samp class="file">libobjc</samp>
library to make an Objective-C program work.
</p>
</dd>
<dt><code class="code"><var class="var">file</var>.mi</code></dt>
<dd><p>Objective-C source code that should not be preprocessed.
</p>
</dd>
<dt><code class="code"><var class="var">file</var>.mm</code></dt>
<dt><code class="code"><var class="var">file</var>.M</code></dt>
<dd><p>Objective-C++ source code.  Note that you must link with the <samp class="file">libobjc</samp>
library to make an Objective-C++ program work.  Note that &lsquo;<samp class="samp">.M</samp>&rsquo; refers
to a literal capital M.
</p>
</dd>
<dt><code class="code"><var class="var">file</var>.mii</code></dt>
<dd><p>Objective-C++ source code that should not be preprocessed.
</p>
</dd>
<dt><code class="code"><var class="var">file</var>.h</code></dt>
<dd><p>C, C++, Objective-C or Objective-C++ header file to be turned into a
precompiled header (default), or C, C++ header file to be turned into an
Ada spec (via the <samp class="option">-fdump-ada-spec</samp> switch).
</p>
</dd>
<dt><code class="code"><var class="var">file</var>.cc</code></dt>
<dt><code class="code"><var class="var">file</var>.cp</code></dt>
<dt><code class="code"><var class="var">file</var>.cxx</code></dt>
<dt><code class="code"><var class="var">file</var>.cpp</code></dt>
<dt><code class="code"><var class="var">file</var>.CPP</code></dt>
<dt><code class="code"><var class="var">file</var>.c++</code></dt>
<dt><code class="code"><var class="var">file</var>.C</code></dt>
<dd><p>C++ source code that must be preprocessed.  Note that in &lsquo;<samp class="samp">.cxx</samp>&rsquo;,
the last two letters must both be literally &lsquo;<samp class="samp">x</samp>&rsquo;.  Likewise,
&lsquo;<samp class="samp">.C</samp>&rsquo; refers to a literal capital C.
</p>
</dd>
<dt><code class="code"><var class="var">file</var>.mm</code></dt>
<dt><code class="code"><var class="var">file</var>.M</code></dt>
<dd><p>Objective-C++ source code that must be preprocessed.
</p>
</dd>
<dt><code class="code"><var class="var">file</var>.mii</code></dt>
<dd><p>Objective-C++ source code that should not be preprocessed.
</p>
</dd>
<dt><code class="code"><var class="var">file</var>.hh</code></dt>
<dt><code class="code"><var class="var">file</var>.H</code></dt>
<dt><code class="code"><var class="var">file</var>.hp</code></dt>
<dt><code class="code"><var class="var">file</var>.hxx</code></dt>
<dt><code class="code"><var class="var">file</var>.hpp</code></dt>
<dt><code class="code"><var class="var">file</var>.HPP</code></dt>
<dt><code class="code"><var class="var">file</var>.h++</code></dt>
<dt><code class="code"><var class="var">file</var>.tcc</code></dt>
<dd><p>C++ header file to be turned into a precompiled header or Ada spec.
</p>
</dd>
<dt><code class="code"><var class="var">file</var>.f</code></dt>
<dt><code class="code"><var class="var">file</var>.for</code></dt>
<dt><code class="code"><var class="var">file</var>.ftn</code></dt>
<dd><p>Fixed form Fortran source code that should not be preprocessed.
</p>
</dd>
<dt><code class="code"><var class="var">file</var>.F</code></dt>
<dt><code class="code"><var class="var">file</var>.FOR</code></dt>
<dt><code class="code"><var class="var">file</var>.fpp</code></dt>
<dt><code class="code"><var class="var">file</var>.FPP</code></dt>
<dt><code class="code"><var class="var">file</var>.FTN</code></dt>
<dd><p>Fixed form Fortran source code that must be preprocessed (with the traditional
preprocessor).
</p>
</dd>
<dt><code class="code"><var class="var">file</var>.f90</code></dt>
<dt><code class="code"><var class="var">file</var>.f95</code></dt>
<dt><code class="code"><var class="var">file</var>.f03</code></dt>
<dt><code class="code"><var class="var">file</var>.f08</code></dt>
<dd><p>Free form Fortran source code that should not be preprocessed.
</p>
</dd>
<dt><code class="code"><var class="var">file</var>.F90</code></dt>
<dt><code class="code"><var class="var">file</var>.F95</code></dt>
<dt><code class="code"><var class="var">file</var>.F03</code></dt>
<dt><code class="code"><var class="var">file</var>.F08</code></dt>
<dd><p>Free form Fortran source code that must be preprocessed (with the
traditional preprocessor).
</p>
</dd>
<dt><code class="code"><var class="var">file</var>.go</code></dt>
<dd><p>Go source code.
</p>
</dd>
<dt><code class="code"><var class="var">file</var>.d</code></dt>
<dd><p>D source code.
</p>
</dd>
<dt><code class="code"><var class="var">file</var>.di</code></dt>
<dd><p>D interface file.
</p>
</dd>
<dt><code class="code"><var class="var">file</var>.dd</code></dt>
<dd><p>D documentation code (Ddoc).
</p>
</dd>
<dt><code class="code"><var class="var">file</var>.ads</code></dt>
<dd><p>Ada source code file that contains a library unit declaration (a
declaration of a package, subprogram, or generic, or a generic
instantiation), or a library unit renaming declaration (a package,
generic, or subprogram renaming declaration).  Such files are also
called <em class="dfn">specs</em>.
</p>
</dd>
<dt><code class="code"><var class="var">file</var>.adb</code></dt>
<dd><p>Ada source code file containing a library unit body (a subprogram or
package body).  Such files are also called <em class="dfn">bodies</em>.
</p>

</dd>
<dt><code class="code"><var class="var">file</var>.s</code></dt>
<dd><p>Assembler code.
</p>
</dd>
<dt><code class="code"><var class="var">file</var>.S</code></dt>
<dt><code class="code"><var class="var">file</var>.sx</code></dt>
<dd><p>Assembler code that must be preprocessed.
</p>
</dd>
<dt><code class="code"><var class="var">other</var></code></dt>
<dd><p>An object file to be fed straight into linking.
Any file name with no recognized suffix is treated this way.
</p></dd>
</dl>

<a class="index-entry-id" id="index-x"></a>
<p>You can specify the input language explicitly with the <samp class="option">-x</samp> option:
</p>
<dl class="table">
<dt><code class="code">-x <var class="var">language</var></code></dt>
<dd><p>Specify explicitly the <var class="var">language</var> for the following input files
(rather than letting the compiler choose a default based on the file
name suffix).  This option applies to all following input files until
the next <samp class="option">-x</samp> option.  Possible values for <var class="var">language</var> are:
</p><div class="example smallexample">
<pre class="example-preformatted">c  c-header  cpp-output
c++  c++-header  c++-system-header c++-user-header c++-cpp-output
objective-c  objective-c-header  objective-c-cpp-output
objective-c++ objective-c++-header objective-c++-cpp-output
assembler  assembler-with-cpp
ada
d
f77  f77-cpp-input f95  f95-cpp-input
go
</pre></div>

</dd>
<dt><code class="code">-x none</code></dt>
<dd><p>Turn off any specification of a language, so that subsequent files are
handled according to their file name suffixes (as they are if <samp class="option">-x</samp>
has not been used at all).
</p></dd>
</dl>

<p>If you only want some of the stages of compilation, you can use
<samp class="option">-x</samp> (or filename suffixes) to tell <code class="command">gcc</code> where to start, and
one of the options <samp class="option">-c</samp>, <samp class="option">-S</samp>, or <samp class="option">-E</samp> to say where
<code class="command">gcc</code> is to stop.  Note that some combinations (for example,
&lsquo;<samp class="samp">-x cpp-output -E</samp>&rsquo;) instruct <code class="command">gcc</code> to do nothing at all.
</p>
<dl class="table">
<dt><a id="index-c"></a><span><code class="code">-c</code><a class="copiable-link" href="#index-c"> &para;</a></span></dt>
<dd><p>Compile or assemble the source files, but do not link.  The linking
stage simply is not done.  The ultimate output is in the form of an
object file for each source file.
</p>
<p>By default, the object file name for a source file is made by replacing
the suffix &lsquo;<samp class="samp">.c</samp>&rsquo;, &lsquo;<samp class="samp">.i</samp>&rsquo;, &lsquo;<samp class="samp">.s</samp>&rsquo;, etc., with &lsquo;<samp class="samp">.o</samp>&rsquo;.
</p>
<p>Unrecognized input files, not requiring compilation or assembly, are
ignored.
</p>
</dd>
<dt><a id="index-S"></a><span><code class="code">-S</code><a class="copiable-link" href="#index-S"> &para;</a></span></dt>
<dd><p>Stop after the stage of compilation proper; do not assemble.  The output
is in the form of an assembler code file for each non-assembler input
file specified.
</p>
<p>By default, the assembler file name for a source file is made by
replacing the suffix &lsquo;<samp class="samp">.c</samp>&rsquo;, &lsquo;<samp class="samp">.i</samp>&rsquo;, etc., with &lsquo;<samp class="samp">.s</samp>&rsquo;.
</p>
<p>Input files that don&rsquo;t require compilation are ignored.
</p>
</dd>
<dt><a id="index-E"></a><span><code class="code">-E</code><a class="copiable-link" href="#index-E"> &para;</a></span></dt>
<dd><p>Stop after the preprocessing stage; do not run the compiler proper.  The
output is in the form of preprocessed source code, which is sent to the
standard output.
</p>
<p>Input files that don&rsquo;t require preprocessing are ignored.
</p>
</dd>
<dt><a class="index-entry-id" id="index-o"></a>
<a id="index-output-file-option"></a><span><code class="code">-o <var class="var">file</var></code><a class="copiable-link" href="#index-output-file-option"> &para;</a></span></dt>
<dd><p>Place the primary output in file <var class="var">file</var>.  This applies to whatever
sort of output is being produced, whether it be an executable file, an
object file, an assembler file or preprocessed C code.
</p>
<p>If <samp class="option">-o</samp> is not specified, the default is to put an executable
file in <samp class="file">a.out</samp>, the object file for
<samp class="file"><var class="var">source</var>.<var class="var">suffix</var></samp> in <samp class="file"><var class="var">source</var>.o</samp>, its
assembler file in <samp class="file"><var class="var">source</var>.s</samp>, a precompiled header file in
<samp class="file"><var class="var">source</var>.<var class="var">suffix</var>.gch</samp>, and all preprocessed C source on
standard output.
</p>
<p>Though <samp class="option">-o</samp> names only the primary output, it also affects the
naming of auxiliary and dump outputs.  See the examples below.  Unless
overridden, both auxiliary outputs and dump outputs are placed in the
same directory as the primary output.  In auxiliary outputs, the suffix
of the input file is replaced with that of the auxiliary output file
type; in dump outputs, the suffix of the dump file is appended to the
input file suffix.  In compilation commands, the base name of both
auxiliary and dump outputs is that of the primary output; in compile and
link commands, the primary output name, minus the executable suffix, is
combined with the input file name.  If both share the same base name,
disregarding the suffix, the result of the combination is that base
name, otherwise, they are concatenated, separated by a dash.
</p>
<div class="example smallexample">
<pre class="example-preformatted">gcc -c foo.c ...
</pre></div>

<p>will use <samp class="file">foo.o</samp> as the primary output, and place aux outputs and
dumps next to it, e.g., aux file <samp class="file">foo.dwo</samp> for
<samp class="option">-gsplit-dwarf</samp>, and dump file <samp class="file">foo.c.???r.final</samp> for
<samp class="option">-fdump-rtl-final</samp>.
</p>
<p>If a non-linker output file is explicitly specified, aux and dump files
by default take the same base name:
</p>
<div class="example smallexample">
<pre class="example-preformatted">gcc -c foo.c -o dir/foobar.o ...
</pre></div>

<p>will name aux outputs <samp class="file">dir/foobar.*</samp> and dump outputs
<samp class="file">dir/foobar.c.*</samp>.
</p>
<p>A linker output will instead prefix aux and dump outputs:
</p>
<div class="example smallexample">
<pre class="example-preformatted">gcc foo.c bar.c -o dir/foobar ...
</pre></div>

<p>will generally name aux outputs <samp class="file">dir/foobar-foo.*</samp> and
<samp class="file">dir/foobar-bar.*</samp>, and dump outputs <samp class="file">dir/foobar-foo.c.*</samp> and
<samp class="file">dir/foobar-bar.c.*</samp>.
</p>
<p>The one exception to the above is when the executable shares the base
name with the single input:
</p>
<div class="example smallexample">
<pre class="example-preformatted">gcc foo.c -o dir/foo ...
</pre></div>

<p>in which case aux outputs are named <samp class="file">dir/foo.*</samp> and dump outputs
named <samp class="file">dir/foo.c.*</samp>.
</p>
<p>The location and the names of auxiliary and dump outputs can be adjusted
by the options <samp class="option">-dumpbase</samp>, <samp class="option">-dumpbase-ext</samp>,
<samp class="option">-dumpdir</samp>, <samp class="option">-save-temps=cwd</samp>, and
<samp class="option">-save-temps=obj</samp>.
</p>

</dd>
<dt><a id="index-dumpbase"></a><span><code class="code">-dumpbase <var class="var">dumpbase</var></code><a class="copiable-link" href="#index-dumpbase"> &para;</a></span></dt>
<dd><p>This option sets the base name for auxiliary and dump output files.  It
does not affect the name of the primary output file.  Intermediate
outputs, when preserved, are not regarded as primary outputs, but as
auxiliary outputs:
</p>
<div class="example smallexample">
<pre class="example-preformatted">gcc -save-temps -S foo.c
</pre></div>

<p>saves the (no longer) temporary preprocessed file in <samp class="file">foo.i</samp>, and
then compiles to the (implied) output file <samp class="file">foo.s</samp>, whereas:
</p>
<div class="example smallexample">
<pre class="example-preformatted">gcc -save-temps -dumpbase save-foo -c foo.c
</pre></div>

<p>preprocesses to in <samp class="file">save-foo.i</samp>, compiles to <samp class="file">save-foo.s</samp> (now
an intermediate, thus auxiliary output), and then assembles to the
(implied) output file <samp class="file">foo.o</samp>.
</p>
<p>Absent this option, dump and aux files take their names from the input
file, or from the (non-linker) output file, if one is explicitly
specified: dump output files (e.g. those requested by <samp class="option">-fdump-*</samp>
options) with the input name suffix, and aux output files (those
requested by other non-dump options, e.g. <code class="code">-save-temps</code>,
<code class="code">-gsplit-dwarf</code>, <code class="code">-fcallgraph-info</code>) without it.
</p>
<p>Similar suffix differentiation of dump and aux outputs can be attained
for explicitly-given <samp class="option">-dumpbase basename.suf</samp> by also specifying
<samp class="option">-dumpbase-ext .suf</samp>.
</p>
<p>If <var class="var">dumpbase</var> is explicitly specified with any directory component,
any <var class="var">dumppfx</var> specification (e.g. <samp class="option">-dumpdir</samp> or
<samp class="option">-save-temps=*</samp>) is ignored, and instead of appending to it,
<var class="var">dumpbase</var> fully overrides it:
</p>
<div class="example smallexample">
<pre class="example-preformatted">gcc foo.c -c -o dir/foo.o -dumpbase alt/foo \
  -dumpdir pfx- -save-temps=cwd ...
</pre></div>

<p>creates auxiliary and dump outputs named <samp class="file">alt/foo.*</samp>, disregarding
<samp class="file">dir/</samp> in <samp class="option">-o</samp>, the <samp class="file">./</samp> prefix implied by
<samp class="option">-save-temps=cwd</samp>, and <samp class="file">pfx-</samp> in <samp class="option">-dumpdir</samp>.
</p>
<p>When <samp class="option">-dumpbase</samp> is specified in a command that compiles multiple
inputs, or that compiles and then links, it may be combined with
<var class="var">dumppfx</var>, as specified under <samp class="option">-dumpdir</samp>.  Then, each input
file is compiled using the combined <var class="var">dumppfx</var>, and default values
for <var class="var">dumpbase</var> and <var class="var">auxdropsuf</var> are computed for each input
file:
</p>
<div class="example smallexample">
<pre class="example-preformatted">gcc foo.c bar.c -c -dumpbase main ...
</pre></div>

<p>creates <samp class="file">foo.o</samp> and <samp class="file">bar.o</samp> as primary outputs, and avoids
overwriting the auxiliary and dump outputs by using the <var class="var">dumpbase</var>
as a prefix, creating auxiliary and dump outputs named <samp class="file">main-foo.*</samp>
and <samp class="file">main-bar.*</samp>.
</p>
<p>An empty string specified as <var class="var">dumpbase</var> avoids the influence of the
output basename in the naming of auxiliary and dump outputs during
compilation, computing default values :
</p>
<div class="example smallexample">
<pre class="example-preformatted">gcc -c foo.c -o dir/foobar.o -dumpbase '' ...
</pre></div>

<p>will name aux outputs <samp class="file">dir/foo.*</samp> and dump outputs
<samp class="file">dir/foo.c.*</samp>.  Note how their basenames are taken from the input
name, but the directory still defaults to that of the output.
</p>
<p>The empty-string dumpbase does not prevent the use of the output
basename for outputs during linking:
</p>
<div class="example smallexample">
<pre class="example-preformatted">gcc foo.c bar.c -o dir/foobar -dumpbase '' -flto ...
</pre></div>

<p>The compilation of the source files will name auxiliary outputs
<samp class="file">dir/foo.*</samp> and <samp class="file">dir/bar.*</samp>, and dump outputs
<samp class="file">dir/foo.c.*</samp> and <samp class="file">dir/bar.c.*</samp>.  LTO recompilation during
linking will use <samp class="file">dir/foobar.</samp> as the prefix for dumps and
auxiliary files.
</p>

</dd>
<dt><a id="index-dumpbase_002dext"></a><span><code class="code">-dumpbase-ext <var class="var">auxdropsuf</var></code><a class="copiable-link" href="#index-dumpbase_002dext"> &para;</a></span></dt>
<dd><p>When forming the name of an auxiliary (but not a dump) output file, drop
trailing <var class="var">auxdropsuf</var> from <var class="var">dumpbase</var> before appending any
suffixes.  If not specified, this option defaults to the suffix of a
default <var class="var">dumpbase</var>, i.e., the suffix of the input file when
<samp class="option">-dumpbase</samp> is not present in the command line, or <var class="var">dumpbase</var>
is combined with <var class="var">dumppfx</var>.
</p>
<div class="example smallexample">
<pre class="example-preformatted">gcc foo.c -c -o dir/foo.o -dumpbase x-foo.c -dumpbase-ext .c ...
</pre></div>

<p>creates <samp class="file">dir/foo.o</samp> as the main output, and generates auxiliary
outputs in <samp class="file">dir/x-foo.*</samp>, taking the location of the primary
output, and dropping the <samp class="file">.c</samp> suffix from the <var class="var">dumpbase</var>.  Dump
outputs retain the suffix: <samp class="file">dir/x-foo.c.*</samp>.
</p>
<p>This option is disregarded if it does not match the suffix of a
specified <var class="var">dumpbase</var>, except as an alternative to the executable
suffix when appending the linker output base name to <var class="var">dumppfx</var>, as
specified below:
</p>
<div class="example smallexample">
<pre class="example-preformatted">gcc foo.c bar.c -o main.out -dumpbase-ext .out ...
</pre></div>

<p>creates <samp class="file">main.out</samp> as the primary output, and avoids overwriting
the auxiliary and dump outputs by using the executable name minus
<var class="var">auxdropsuf</var> as a prefix, creating auxiliary outputs named
<samp class="file">main-foo.*</samp> and <samp class="file">main-bar.*</samp> and dump outputs named
<samp class="file">main-foo.c.*</samp> and <samp class="file">main-bar.c.*</samp>.
</p>

</dd>
<dt><a id="index-dumpdir"></a><span><code class="code">-dumpdir <var class="var">dumppfx</var></code><a class="copiable-link" href="#index-dumpdir"> &para;</a></span></dt>
<dd><p>When forming the name of an auxiliary or dump output file, use
<var class="var">dumppfx</var> as a prefix:
</p>
<div class="example smallexample">
<pre class="example-preformatted">gcc -dumpdir pfx- -c foo.c ...
</pre></div>

<p>creates <samp class="file">foo.o</samp> as the primary output, and auxiliary outputs named
<samp class="file">pfx-foo.*</samp>, combining the given <var class="var">dumppfx</var> with the default
<var class="var">dumpbase</var> derived from the default primary output, derived in turn
from the input name.  Dump outputs also take the input name suffix:
<samp class="file">pfx-foo.c.*</samp>.
</p>
<p>If <var class="var">dumppfx</var> is to be used as a directory name, it must end with a
directory separator:
</p>
<div class="example smallexample">
<pre class="example-preformatted">gcc -dumpdir dir/ -c foo.c -o obj/bar.o ...
</pre></div>

<p>creates <samp class="file">obj/bar.o</samp> as the primary output, and auxiliary outputs
named <samp class="file">dir/bar.*</samp>, combining the given <var class="var">dumppfx</var> with the
default <var class="var">dumpbase</var> derived from the primary output name.  Dump
outputs also take the input name suffix: <samp class="file">dir/bar.c.*</samp>.
</p>
<p>It defaults to the location of the output file, unless the output
file is a special file like <code class="code">/dev/null</code>. Options
<samp class="option">-save-temps=cwd</samp> and <samp class="option">-save-temps=obj</samp> override this
default, just like an explicit <samp class="option">-dumpdir</samp> option.  In case
multiple such options are given, the last one prevails:
</p>
<div class="example smallexample">
<pre class="example-preformatted">gcc -dumpdir pfx- -c foo.c -save-temps=obj ...
</pre></div>

<p>outputs <samp class="file">foo.o</samp>, with auxiliary outputs named <samp class="file">foo.*</samp> because
<samp class="option">-save-temps=*</samp> overrides the <var class="var">dumppfx</var> given by the earlier
<samp class="option">-dumpdir</samp> option.  It does not matter that <samp class="option">=obj</samp> is the
default for <samp class="option">-save-temps</samp>, nor that the output directory is
implicitly the current directory.  Dump outputs are named
<samp class="file">foo.c.*</samp>.
</p>
<p>When compiling from multiple input files, if <samp class="option">-dumpbase</samp> is
specified, <var class="var">dumpbase</var>, minus a <var class="var">auxdropsuf</var> suffix, and a dash
are appended to (or override, if containing any directory components) an
explicit or defaulted <var class="var">dumppfx</var>, so that each of the multiple
compilations gets differently-named aux and dump outputs.
</p>
<div class="example smallexample">
<pre class="example-preformatted">gcc foo.c bar.c -c -dumpdir dir/pfx- -dumpbase main ...
</pre></div>

<p>outputs auxiliary dumps to <samp class="file">dir/pfx-main-foo.*</samp> and
<samp class="file">dir/pfx-main-bar.*</samp>, appending <var class="var">dumpbase</var>- to <var class="var">dumppfx</var>.
Dump outputs retain the input file suffix: <samp class="file">dir/pfx-main-foo.c.*</samp>
and <samp class="file">dir/pfx-main-bar.c.*</samp>, respectively.  Contrast with the
single-input compilation:
</p>
<div class="example smallexample">
<pre class="example-preformatted">gcc foo.c -c -dumpdir dir/pfx- -dumpbase main ...
</pre></div>

<p>that, applying <samp class="option">-dumpbase</samp> to a single source, does not compute
and append a separate <var class="var">dumpbase</var> per input file.  Its auxiliary and
dump outputs go in <samp class="file">dir/pfx-main.*</samp>.
</p>
<p>When compiling and then linking from multiple input files, a defaulted
or explicitly specified <var class="var">dumppfx</var> also undergoes the <var class="var">dumpbase</var>-
transformation above (e.g. the compilation of <samp class="file">foo.c</samp> and
<samp class="file">bar.c</samp> above, but without <samp class="option">-c</samp>).  If neither
<samp class="option">-dumpdir</samp> nor <samp class="option">-dumpbase</samp> are given, the linker output
base name, minus <var class="var">auxdropsuf</var>, if specified, or the executable
suffix otherwise, plus a dash is appended to the default <var class="var">dumppfx</var>
instead.  Note, however, that unlike earlier cases of linking:
</p>
<div class="example smallexample">
<pre class="example-preformatted">gcc foo.c bar.c -dumpdir dir/pfx- -o main ...
</pre></div>

<p>does not append the output name <samp class="file">main</samp> to <var class="var">dumppfx</var>, because
<samp class="option">-dumpdir</samp> is explicitly specified.  The goal is that the
explicitly-specified <var class="var">dumppfx</var> may contain the specified output name
as part of the prefix, if desired; only an explicitly-specified
<samp class="option">-dumpbase</samp> would be combined with it, in order to avoid simply
discarding a meaningful option.
</p>
<p>When compiling and then linking from a single input file, the linker
output base name will only be appended to the default <var class="var">dumppfx</var> as
above if it does not share the base name with the single input file
name.  This has been covered in single-input linking cases above, but
not with an explicit <samp class="option">-dumpdir</samp> that inhibits the combination,
even if overridden by <samp class="option">-save-temps=*</samp>:
</p>
<div class="example smallexample">
<pre class="example-preformatted">gcc foo.c -dumpdir alt/pfx- -o dir/main.exe -save-temps=cwd ...
</pre></div>

<p>Auxiliary outputs are named <samp class="file">foo.*</samp>, and dump outputs
<samp class="file">foo.c.*</samp>, in the current working directory as ultimately requested
by <samp class="option">-save-temps=cwd</samp>.
</p>
<p>Summing it all up for an intuitive though slightly imprecise data flow:
the primary output name is broken into a directory part and a basename
part; <var class="var">dumppfx</var> is set to the former, unless overridden by
<samp class="option">-dumpdir</samp> or <samp class="option">-save-temps=*</samp>, and <var class="var">dumpbase</var> is set
to the latter, unless overriden by <samp class="option">-dumpbase</samp>.  If there are
multiple inputs or linking, this <var class="var">dumpbase</var> may be combined with
<var class="var">dumppfx</var> and taken from each input file.  Auxiliary output names
for each input are formed by combining <var class="var">dumppfx</var>, <var class="var">dumpbase</var>
minus suffix, and the auxiliary output suffix; dump output names are
only different in that the suffix from <var class="var">dumpbase</var> is retained.
</p>
<p>When it comes to auxiliary and dump outputs created during LTO
recompilation, a combination of <var class="var">dumppfx</var> and <var class="var">dumpbase</var>, as
given or as derived from the linker output name but not from inputs,
even in cases in which this combination would not otherwise be used as
such, is passed down with a trailing period replacing the compiler-added
dash, if any, as a <samp class="option">-dumpdir</samp> option to <code class="command">lto-wrapper</code>;
being involved in linking, this program does not normally get any
<samp class="option">-dumpbase</samp> and <samp class="option">-dumpbase-ext</samp>, and it ignores them.
</p>
<p>When running sub-compilers, <code class="command">lto-wrapper</code> appends LTO stage
names to the received <var class="var">dumppfx</var>, ensures it contains a directory
component so that it overrides any <samp class="option">-dumpdir</samp>, and passes that as
<samp class="option">-dumpbase</samp> to sub-compilers.
</p>
</dd>
<dt><a id="index-v"></a><span><code class="code">-v</code><a class="copiable-link" href="#index-v"> &para;</a></span></dt>
<dd><p>Print (on standard error output) the commands executed to run the stages
of compilation.  Also print the version number of the compiler driver
program and of the preprocessor and the compiler proper.
</p>
</dd>
<dt><a id="index-_0023_0023_0023"></a><span><code class="code">-###</code><a class="copiable-link" href="#index-_0023_0023_0023"> &para;</a></span></dt>
<dd><p>Like <samp class="option">-v</samp> except the commands are not executed and arguments
are quoted unless they contain only alphanumeric characters or <code class="code">./-_</code>.
This is useful for shell scripts to capture the driver-generated command lines.
</p>
</dd>
<dt><a id="index-help"></a><span><code class="code">--help</code><a class="copiable-link" href="#index-help"> &para;</a></span></dt>
<dd><p>Print (on the standard output) a description of the command-line options
understood by <code class="command">gcc</code>.  If the <samp class="option">-v</samp> option is also specified
then <samp class="option">--help</samp> is also passed on to the various processes
invoked by <code class="command">gcc</code>, so that they can display the command-line options
they accept.  If the <samp class="option">-Wextra</samp> option has also been specified
(prior to the <samp class="option">--help</samp> option), then command-line options that
have no documentation associated with them are also displayed.
</p>
</dd>
<dt><a id="index-target_002dhelp"></a><span><code class="code">--target-help</code><a class="copiable-link" href="#index-target_002dhelp"> &para;</a></span></dt>
<dd><p>Print (on the standard output) a description of target-specific command-line
options for each tool.  For some targets extra target-specific
information may also be printed.
</p>
</dd>
<dt><code class="code">--help={<var class="var">class</var><span class="r">|[</span>^<span class="r">]</span><var class="var">qualifier</var>}<span class="r">[</span>,&hellip;<span class="r">]</span></code></dt>
<dd><p>Print (on the standard output) a description of the command-line
options understood by the compiler that fit into all specified classes
and qualifiers.  These are the supported classes:
</p>
<dl class="table">
<dt>&lsquo;<samp class="samp">optimizers</samp>&rsquo;</dt>
<dd><p>Display all of the optimization options supported by the
compiler.
</p>
</dd>
<dt>&lsquo;<samp class="samp">warnings</samp>&rsquo;</dt>
<dd><p>Display all of the options controlling warning messages
produced by the compiler.
</p>
</dd>
<dt>&lsquo;<samp class="samp">target</samp>&rsquo;</dt>
<dd><p>Display target-specific options.  Unlike the
<samp class="option">--target-help</samp> option however, target-specific options of the
linker and assembler are not displayed.  This is because those
tools do not currently support the extended <samp class="option">--help=</samp> syntax.
</p>
</dd>
<dt>&lsquo;<samp class="samp">params</samp>&rsquo;</dt>
<dd><p>Display the values recognized by the <samp class="option">--param</samp>
option.
</p>
</dd>
<dt><var class="var">language</var></dt>
<dd><p>Display the options supported for <var class="var">language</var>, where
<var class="var">language</var> is the name of one of the languages supported in this
version of GCC.  If an option is supported by all languages, one needs
to select &lsquo;<samp class="samp">common</samp>&rsquo; class.
</p>
</dd>
<dt>&lsquo;<samp class="samp">common</samp>&rsquo;</dt>
<dd><p>Display the options that are common to all languages.
</p></dd>
</dl>

<p>These are the supported qualifiers:
</p>
<dl class="table">
<dt>&lsquo;<samp class="samp">undocumented</samp>&rsquo;</dt>
<dd><p>Display only those options that are undocumented.
</p>
</dd>
<dt>&lsquo;<samp class="samp">joined</samp>&rsquo;</dt>
<dd><p>Display options taking an argument that appears after an equal
sign in the same continuous piece of text, such as:
&lsquo;<samp class="samp">--help=target</samp>&rsquo;.
</p>
</dd>
<dt>&lsquo;<samp class="samp">separate</samp>&rsquo;</dt>
<dd><p>Display options taking an argument that appears as a separate word
following the original option, such as: &lsquo;<samp class="samp">-o output-file</samp>&rsquo;.
</p></dd>
</dl>

<p>Thus for example to display all the undocumented target-specific
switches supported by the compiler, use:
</p>
<div class="example smallexample">
<pre class="example-preformatted">--help=target,undocumented
</pre></div>

<p>The sense of a qualifier can be inverted by prefixing it with the
&lsquo;<samp class="samp">^</samp>&rsquo; character, so for example to display all binary warning
options (i.e., ones that are either on or off and that do not take an
argument) that have a description, use:
</p>
<div class="example smallexample">
<pre class="example-preformatted">--help=warnings,^joined,^undocumented
</pre></div>

<p>The argument to <samp class="option">--help=</samp> should not consist solely of inverted
qualifiers.
</p>
<p>Combining several classes is possible, although this usually
restricts the output so much that there is nothing to display.  One
case where it does work, however, is when one of the classes is
<var class="var">target</var>.  For example, to display all the target-specific
optimization options, use:
</p>
<div class="example smallexample">
<pre class="example-preformatted">--help=target,optimizers
</pre></div>

<p>The <samp class="option">--help=</samp> option can be repeated on the command line.  Each
successive use displays its requested class of options, skipping
those that have already been displayed.  If <samp class="option">--help</samp> is also
specified anywhere on the command line then this takes precedence
over any <samp class="option">--help=</samp> option.
</p>
<p>If the <samp class="option">-Q</samp> option appears on the command line before the
<samp class="option">--help=</samp> option, then the descriptive text displayed by
<samp class="option">--help=</samp> is changed.  Instead of describing the displayed
options, an indication is given as to whether the option is enabled,
disabled or set to a specific value (assuming that the compiler
knows this at the point where the <samp class="option">--help=</samp> option is used).
</p>
<p>Here is a truncated example from the ARM port of <code class="command">gcc</code>:
</p>
<div class="example smallexample">
<pre class="example-preformatted">  % gcc -Q -mabi=2 --help=target -c
  The following options are target specific:
  -mabi=                                2
  -mabort-on-noreturn                   [disabled]
  -mapcs                                [disabled]
</pre></div>

<p>The output is sensitive to the effects of previous command-line
options, so for example it is possible to find out which optimizations
are enabled at <samp class="option">-O2</samp> by using:
</p>
<div class="example smallexample">
<pre class="example-preformatted">-Q -O2 --help=optimizers
</pre></div>

<p>Alternatively you can discover which binary optimizations are enabled
by <samp class="option">-O3</samp> by using:
</p>
<div class="example smallexample">
<pre class="example-preformatted">gcc -c -Q -O3 --help=optimizers &gt; /tmp/O3-opts
gcc -c -Q -O2 --help=optimizers &gt; /tmp/O2-opts
diff /tmp/O2-opts /tmp/O3-opts | grep enabled
</pre></div>

</dd>
<dt><a id="index-version"></a><span><code class="code">--version</code><a class="copiable-link" href="#index-version"> &para;</a></span></dt>
<dd><p>Display the version number and copyrights of the invoked GCC.
</p>
</dd>
<dt><a id="index-pass_002dexit_002dcodes"></a><span><code class="code">-pass-exit-codes</code><a class="copiable-link" href="#index-pass_002dexit_002dcodes"> &para;</a></span></dt>
<dd><p>Normally the <code class="command">gcc</code> program exits with the code of 1 if any
phase of the compiler returns a non-success return code.  If you specify
<samp class="option">-pass-exit-codes</samp>, the <code class="command">gcc</code> program instead returns with
the numerically highest error produced by any phase returning an error
indication.  The C, C++, and Fortran front ends return 4 if an internal
compiler error is encountered.
</p>
</dd>
<dt><a id="index-pipe"></a><span><code class="code">-pipe</code><a class="copiable-link" href="#index-pipe"> &para;</a></span></dt>
<dd><p>Use pipes rather than temporary files for communication between the
various stages of compilation.  This fails to work on some systems where
the assembler is unable to read from a pipe; but the GNU assembler has
no trouble.
</p>
</dd>
<dt><a id="index-specs"></a><span><code class="code">-specs=<var class="var">file</var></code><a class="copiable-link" href="#index-specs"> &para;</a></span></dt>
<dd><p>Process <var class="var">file</var> after the compiler reads in the standard <samp class="file">specs</samp>
file, in order to override the defaults which the <code class="command">gcc</code> driver
program uses when determining what switches to pass to <code class="command">cc1</code>,
<code class="command">cc1plus</code>, <code class="command">as</code>, <code class="command">ld</code>, etc.  More than one
<samp class="option">-specs=<var class="var">file</var></samp> can be specified on the command line, and they
are processed in order, from left to right.  See <a class="xref" href="Spec-Files.html">Specifying Subprocesses and the Switches to Pass to Them</a>, for
information about the format of the <var class="var">file</var>.
</p>
</dd>
<dt><a id="index-wrapper"></a><span><code class="code">-wrapper</code><a class="copiable-link" href="#index-wrapper"> &para;</a></span></dt>
<dd><p>Invoke all subcommands under a wrapper program.  The name of the
wrapper program and its parameters are passed as a comma separated
list.
</p>
<div class="example smallexample">
<pre class="example-preformatted">gcc -c t.c -wrapper gdb,--args
</pre></div>

<p>This invokes all subprograms of <code class="command">gcc</code> under
&lsquo;<samp class="samp">gdb --args</samp>&rsquo;, thus the invocation of <code class="command">cc1</code> is
&lsquo;<samp class="samp">gdb --args cc1 &hellip;</samp>&rsquo;.
</p>
</dd>
<dt><a id="index-ffile_002dprefix_002dmap"></a><span><code class="code">-ffile-prefix-map=<var class="var">old</var>=<var class="var">new</var></code><a class="copiable-link" href="#index-ffile_002dprefix_002dmap"> &para;</a></span></dt>
<dd><p>When compiling files residing in directory <samp class="file"><var class="var">old</var></samp>, record
any references to them in the result of the compilation as if the
files resided in directory <samp class="file"><var class="var">new</var></samp> instead.  Specifying this
option is equivalent to specifying all the individual
<samp class="option">-f*-prefix-map</samp> options.  This can be used to make reproducible
builds that are location independent.  Directories referenced by
directives are not affected by these options.  See also
<samp class="option">-fmacro-prefix-map</samp>, <samp class="option">-fdebug-prefix-map</samp>,
<samp class="option">-fprofile-prefix-map</samp> and <samp class="option">-fcanon-prefix-map</samp>.
</p>
</dd>
<dt><a id="index-fcanon_002dprefix_002dmap"></a><span><code class="code">-fcanon-prefix-map</code><a class="copiable-link" href="#index-fcanon_002dprefix_002dmap"> &para;</a></span></dt>
<dd><p>For the <samp class="option">-f*-prefix-map</samp> options normally comparison
of <samp class="file"><var class="var">old</var></samp> prefix against the filename that would be normally
referenced in the result of the compilation is done using textual
comparison of the prefixes, or ignoring character case for case insensitive
filesystems and considering slashes and backslashes as equal on DOS based
filesystems.  The <samp class="option">-fcanon-prefix-map</samp> causes such comparisons
to be done on canonicalized paths of <samp class="file"><var class="var">old</var></samp>
and the referenced filename.
</p>
</dd>
<dt><a id="index-fplugin"></a><span><code class="code">-fplugin=<var class="var">name</var>.so</code><a class="copiable-link" href="#index-fplugin"> &para;</a></span></dt>
<dd><p>Load the plugin code in file <var class="var">name</var>.so, assumed to be a
shared object to be dlopen&rsquo;d by the compiler.  The base name of
the shared object file is used to identify the plugin for the
purposes of argument parsing (See
<samp class="option">-fplugin-arg-<var class="var">name</var>-<var class="var">key</var>=<var class="var">value</var></samp> below).
Each plugin should define the callback functions specified in the
Plugins API.
</p>
</dd>
<dt><a id="index-fplugin_002darg"></a><span><code class="code">-fplugin-arg-<var class="var">name</var>-<var class="var">key</var>=<var class="var">value</var></code><a class="copiable-link" href="#index-fplugin_002darg"> &para;</a></span></dt>
<dd><p>Define an argument called <var class="var">key</var> with a value of <var class="var">value</var>
for the plugin called <var class="var">name</var>.
</p>
</dd>
<dt><a id="index-fdump_002dada_002dspec"></a><span><code class="code">-fdump-ada-spec<span class="r">[</span>-slim<span class="r">]</span></code><a class="copiable-link" href="#index-fdump_002dada_002dspec"> &para;</a></span></dt>
<dd><p>For C and C++ source and include files, generate corresponding Ada specs.
See <a data-manual="gnat_ugn" href="https://gcc.gnu.org/onlinedocs/gnat_ugn/Generating-Ada-Bindings-for-C-and-C_002b_002b-headers.html#Generating-Ada-Bindings-for-C-and-C_002b_002b-headers">Generating Ada Bindings for C and C++ headers</a> in <cite class="cite">GNAT User&rsquo;s Guide</cite>, which provides detailed documentation on this feature.
</p>
</dd>
<dt><a id="index-fada_002dspec_002dparent"></a><span><code class="code">-fada-spec-parent=<var class="var">unit</var></code><a class="copiable-link" href="#index-fada_002dspec_002dparent"> &para;</a></span></dt>
<dd><p>In conjunction with <samp class="option">-fdump-ada-spec<span class="r">[</span>-slim<span class="r">]</span></samp> above, generate
Ada specs as child units of parent <var class="var">unit</var>.
</p>
</dd>
<dt><a id="index-fdump_002dgo_002dspec"></a><span><code class="code">-fdump-go-spec=<var class="var">file</var></code><a class="copiable-link" href="#index-fdump_002dgo_002dspec"> &para;</a></span></dt>
<dd><p>For input files in any language, generate corresponding Go
declarations in <var class="var">file</var>.  This generates Go <code class="code">const</code>,
<code class="code">type</code>, <code class="code">var</code>, and <code class="code">func</code> declarations which may be a
useful way to start writing a Go interface to code written in some
other language.
</p>

</dd>
<dt><code class="code">@<var class="var">file</var></code></dt>
<dd><p>Read command-line options from <var class="var">file</var>.  The options read are
inserted in place of the original @<var class="var">file</var> option.  If <var class="var">file</var>
does not exist, or cannot be read, then the option will be treated
literally, and not removed.  
</p>
<p>Options in <var class="var">file</var> are separated by whitespace.  A whitespace
character may be included in an option by surrounding the entire
option in either single or double quotes.  Any character (including a
backslash) may be included by prefixing the character to be included
with a backslash.  The <var class="var">file</var> may itself contain additional
@<var class="var">file</var> options; any such options will be processed recursively.
</p></dd>
</dl>

</div>
<hr>
<div class="nav-panel">
<p>
Next: <a href="Invoking-G_002b_002b.html">Compiling C++ Programs</a>, Previous: <a href="Option-Summary.html">Option Summary</a>, Up: <a href="Invoking-GCC.html">GCC Command Options</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Indices.html" title="Index" rel="index">Index</a>]</p>
</div>



</body>
</html>
